const app = getApp()
Page({
  data: {

  },
  meal1: function () {
    var that = this;
    that.setData({
      id: 1
    })
  },
  meal2: function () {
    var that = this;
    that.setData({
      id: 2
    })
  },
  meal3: function () {
    var that = this;
    that.setData({
      id: 3
    })
  },
  return_shipment: function () {
    wx.navigateTo({
      url: '/pages/network/shipment',
    })
  },

  onLoad: function(){
    var that = this;
    var cookie = wx.getStorageSync("cookie");
    that.setData({
      cookie: cookie
    })
  },
  /* onShow: function (options) {
     var that = this;
     var username = wx.getStorageSync('student_id');
     //var password = wx.getStorageSync('campus_password')
     console.log(username)
    // console.log(password)
     wx.request({
       url: app.globalData.ip_url + 'api/net/search/',
       method: 'post',
       header: {
         'Content-type': 'application/x-www-form-urlencoded'
       },
       data: {
         username: username
       },
       success: res => {   
         var temp= parseFloat(res.data.data.serivce[5] + res.data.data.serivce[6]);
         var temps=[];
         if(temp=="25") temps=[1,0,0];
         if (temp == "50") temps=[0,1,0];
         if (temp == "75") temps=[0,0,1];
 
 
         console.log(temp);
         that.setData({       
           temps:temps
         })
         console.log(temps);
         
       }
     })
   },
   */
  bind_to_change: function () {
    var that = this;
    var id = that.data.id;
    var cookie = that.data.cookie;
    console.log("cookie=" + cookie);
    console.log("id="+ id);
    wx.request({
      url: app.globalData.netUrl + 'api/net/changemeal/',
      method: 'post',
      header: {
        "content-type": "application/x-www-form-urlencoded",
      },
      data: {
        id: id,
        "Cookie": cookie
      },

      success: res => {
        if (res.data.msg) {
          wx.showModal({
            content: res.data.msg,
            showCancel: false
          })
        }
      }
    })
  },
  //套餐选择，1为10元10G，2为20元20G，3为30元30G
})